<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 141. 环形链表
        head = [3, 2, 0, -4]
        var hasCycle = function (head) {
            if (head == null || head.next == null || head.next.next == null) { return false }
            let n1 = head
            let nn = head.next
            while (n1 != nn) {
                if (nn.next == null || nn.next.next == null) {
                    return false
                }
                n1 = n1.next
                nn = nn.next.next
            }
            return true
        };
        console.log(hasCycle(head));
    </script>
</body>

</html>